package com.antler.smt.portal.controller;

import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.portal.utils.FormatListUtil;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.JobOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * 工作订单的操作
 *
 * @author zhangyi
 * @date 2018/9/20 14:59
 */
@RestController
@RequestMapping("/jobOrder")
@Api(description = "对于工作订单的一系列的操作")
@Slf4j
public class JobOrderOperateController extends BaseController{
    @Resource
    private JobOrderService jobOrderService;

    /**
     * 查看详细的订单信息
     *
     * @return
     */
    @GetMapping("/detailedOrder/{orderId}")
    @ApiOperation(value = "查看详细的订单信息",httpMethod = "GET")
    @OperateCut(operationContent = "查看详细的订单信息")
    public Result detailedOrder(@PathVariable(value = "orderId") Long orderId){
        return jobOrderService.detailedOrder(orderId);
    }
    /**
     * 批量删除订单
     *
     * @param orderIds
     * @return
     */
    @DeleteMapping("/batchDeleteOrder")
    @ApiOperation(value = "批量删除订单",httpMethod = "DELETE")
    @OperateCut(operationContent = "批量删除订单")
    public Result batchDeleteOrder(List<Integer> orderIds){
        return jobOrderService.batchDeleteOrder(orderIds);
    }

    /**
     * 彻底删除订单
     *
     * @param orderId
     * @return
     */
    @DeleteMapping("/deleteThoroughOrder/{orderId}")
    @ApiOperation(value = "从订单回收站彻底删除订单",httpMethod = "DELETE")
    @OperateCut(operationContent = "从订单回收站彻底删除订单各个订单id用,号分割")
    public Result deleteThoroughOrder(@PathVariable(value = "orderId") String orderId){
        return jobOrderService.deleteThoroughOrder(FormatListUtil.pareIntLists(orderId));
    }
    /**
     * 分类查看订单列表
     *
     * @return
     */
    @GetMapping("/jobOrderList/{orderStatus}")
    @ApiOperation(value = "查看订单列表(用,号分隔订单状态)0 已提交，待审核（500 驳回）1 已通过,待付款 2 待确认付款 3 匹配中（600 失败）4 合作中 5 已完成 6 评价",httpMethod = "GET")
    @OperateCut(operationContent = "查看订单列表")
    public Result jobOrderList(@PathVariable(value = "orderStatus") String orderStatus){
        return jobOrderService.jobOrderList(FormatListUtil.pareIntLists(orderStatus),currentMember.getId());
    }

    /**
     * 查看回收站订单列表
     *
     * @return
     */
    @GetMapping("/recycleBinOrderLists")
    @ApiOperation(value = "查看回收站订单列表",httpMethod = "GET")
    @OperateCut(operationContent = "查看回收站订单列表")
    public Result recycleBinOrderLists(){
        return jobOrderService.recycleBinOrderLists(currentMember.getId());
    }
}
